export default {
  setUid(state, value) {
    state.uid = value;
  },

  setUserInfo(state, value) {
    state.userEssay = '';
    state.analysisResult = null;
    sessionStorage.removeItem('userEssay');
    sessionStorage.removeItem('analysisResult');

    localStorage.setItem('username', value.username);
    localStorage.setItem('uid', value.id);
    localStorage.setItem('avatar', value.avatar);

    state.uid = value.id;
    state.username = value.username;
    state.avatar = value.avatar;
  },

  setUserEssay(state, essay) {
    console.log("Mutation - setUserEssay 被调用，更新为：", essay);
    state.userEssay = essay;
    sessionStorage.setItem('userEssay', essay);
  },

  clearAnalysisData(state) {
    state.userEssay = '';
    sessionStorage.removeItem('userEssay');
  },
};
